home *** CD-ROM | disk | FTP | other *** search
/ com!online 2005 May / com_0505_1.iso / opensource / top10 / amc_install.exe / {app} / Scripts / Cineguide_nl.ifs < prev    next >
Encoding:
Text File  |  2004-03-20  |  6.3 KB  |  189 lines

  1. // GETINFO SCRIPTING
  2. // Cineguide (Cinebel) - Dutch (BE) import
  3.  
  4. (***************************************************
  5.  *  Movie importation script for:                  *
  6.  *  CINEGUIDE DUTCH (BE), http://www.cineguide.be  *
  7.  *                                                 *
  8.  *  Script made by Epsilon                         *
  9.  *  New version made by Antoine Potten             *
  10.  *                                                 *
  11.  *  For use with Ant Movie Catalog 3.4.0           *
  12.  *  www.antp.be/software/moviecatalog              *
  13.  *                                                 *
  14.  *  This program is free software; you can         *
  15.  *  redistribute it and/or modify it under the     *
  16.  *  terms of the GNU General Public License as     *
  17.  *  published by the Free Software Foundation;     *
  18.  *  either version 2 of the License, or (at your   *
  19.  *  option) any later version.                     *
  20.  ***************************************************)
  21.  
  22. program CINEGUIDE_NL;
  23. var
  24.   MovieName: string;
  25.  
  26. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  27. var
  28.   i: Integer;
  29. begin
  30.   result := -1;
  31.   if StartAt < 0 then
  32.     StartAt := 0;
  33.   for i := StartAt to List.Count-1 do
  34.     if Pos(Pattern, List.GetString(i)) <> 0 then
  35.     begin
  36.       result := i;
  37.       Break;
  38.     end;
  39. end;
  40.  
  41. procedure AnalyzePage(Address: string);
  42. var
  43.   PageText: string;
  44.   Block: string;
  45.   ResultBlock: Integer;
  46.   BeginPos, EndPos: Integer;
  47.   ValueTitle, ValueAddress: string;
  48. begin
  49.   PageText := GetPage(Address);
  50.   if pos('<a href=/fr/film.asp', PageText) > 0 then
  51.   begin
  52.     SetField(fieldURL, Address);
  53.     AnalyzeMoviePage(PageText)
  54.   end
  55.   else
  56.   begin
  57.     PickTreeClear;
  58.     ResultBlock := Pos('<td class="cadre" height="16">', PageText);
  59.     while ResultBlock > 0 do
  60.     begin
  61.       Delete(PageText, 1, ResultBlock + 35);
  62.       EndPos := Pos('</td>', PageText);
  63.       PickTreeAdd(StringReplace(Copy(PageText, 1, EndPos - 1), #13#10 + '                   ', ''), '');
  64.       BeginPos := EndPos;
  65.       EndPos := Pos('<td height="10"> </td>', PageText);
  66.       Block := Copy(PageText, BeginPos, EndPos - BeginPos);
  67.       Delete(PageText, 1, EndPos);
  68.       BeginPos := Pos('<a href="/nl/film.asp', Block);
  69.       while BeginPos > 0 do
  70.       begin
  71.         Delete(Block, 1, BeginPos - 1);
  72.         EndPos := Pos('</a>', Block);
  73.         ValueTitle := Copy(Block, 1, EndPos - 1);
  74.         HTMLRemoveTags(ValueTitle);
  75.         BeginPos := Pos('"', Block);
  76.         EndPos := Pos('" class', Block);
  77.         ValueAddress := 'http://www.cinebel.be' + Copy(Block, BeginPos + 1, EndPos - BeginPos - 1);
  78.         PickTreeAdd(ValueTitle, ValueAddress);
  79.         EndPos := Pos('</td>', Block);
  80.         Delete(Block, 1, EndPos);
  81.         BeginPos := Pos('<a href="/nl/film.asp', Block);
  82.       end;
  83.       ResultBlock := Pos('<td class="cadre" height="16">', PageText);
  84.     end;
  85.     if PickTreeExec(Address) then
  86.       AnalyzePage(Address);
  87.   end;
  88. end;
  89.  
  90. procedure AnalyzeMoviePage(PageText: string);
  91. var
  92.   Line, Value: string;
  93.   IntValue: Integer;
  94.   BeginPos, EndPos: Integer;
  95. begin
  96.   BeginPos := Pos('<table border="0" width="95%" cellpadding="0" cellspacing="0">', PageText);
  97.   Delete(PageText, 1, BeginPos);
  98.  
  99.   // Original Title
  100.   BeginPos := Pos('<b class="cadre">', PageText);
  101.   Delete(PageText, 1, BeginPos + 16);
  102.   EndPos := Pos ('</b>', PageText);
  103.   Value := Copy(PageText, 1, EndPos - 1);
  104.   SetField(fieldOriginalTitle, Value);
  105.  
  106.   // Country & Year
  107.   BeginPos := Pos(' - ', PageText) + 3;
  108.   EndPos := Pos('</td>', PageText);
  109.   Line := Copy(PageText, BeginPos, EndPos - BeginPos);
  110.   EndPos := Pos(' - ', Line);
  111.   SetField(fieldCountry, Copy(Line, 1, EndPos - 1));
  112.   Delete(Line, 1, EndPos + 2);
  113.   EndPos := Pos(#13#10, Line);
  114.   SetField(fieldYear, Copy(Line, 1, EndPos - 1));
  115.  
  116.   // Description
  117.   BeginPos := Pos('<hr noshade width="100%" size="1" color="#000000">', PageText);
  118.   Delete(PageText, 1, BeginPos);
  119.   EndPos := Pos('<hr noshade width="100%" size="1" color="#000000">', PageText);
  120.   Line := Copy(PageText, 1, EndPos - 1);
  121.   Delete(PageText, 1, EndPos);
  122.   BeginPos := Pos('>', Line);
  123.   Delete(Line, 1, BeginPos);
  124.   Line := StringReplace(Trim(StringReplace(Line, #13#10, '')), '<br>', #13#10);
  125.   SetField(fieldDescription, Line);
  126.   
  127.   // Director
  128.   BeginPos := Pos('<b>Regisseur', PageText);
  129.   Delete(PageText, 1, BeginPos);
  130.   BeginPos := Pos('</b> ', PageText) + 5;
  131.   EndPos := Pos('</td>', PageText);
  132.   Value := Copy(PageText, BeginPos, EndPos - BeginPos);
  133.   HTMLRemoveTags(Value);
  134.   SetField(fieldDirector, Value);
  135.   
  136.   // Actors
  137.   BeginPos := Pos('<b>Acteurs', PageText);
  138.   Delete(PageText, 1, BeginPos);
  139.   BeginPos := Pos(' </b>', PageText) + 5;
  140.   EndPos := Pos('</td>', PageText);
  141.   Value := Copy(PageText, BeginPos, EndPos - BeginPos);
  142.   Value := StringReplace(Value, '                        ', '');
  143.   Value := StringReplace(Value, #13#10, '');
  144.   HTMLRemoveTags(Value);
  145.   SetField(fieldActors, Trim(Value));
  146.   
  147.   // Category
  148.   BeginPos := Pos('<b>Genre', PageText);
  149.   Delete(PageText, 1, BeginPos);
  150.   BeginPos := Pos('</b> ', PageText) + 5;
  151.   EndPos := Pos('</td>', PageText);
  152.   Value := Copy(PageText, BeginPos, EndPos - BeginPos);
  153.   EndPos := Pos(#13#10, Value);
  154.   SetField(fieldCategory, Copy(Value, 1, EndPos - 1));
  155.   
  156.   // Length
  157.   BeginPos := Pos('<b>Duur', PageText);
  158.   Delete(PageText, 1, BeginPos);
  159.   BeginPos := Pos(' </b>', PageText) + 5;
  160.   EndPos := Pos(' </td>', PageText);
  161.   Value := Copy(PageText, BeginPos, EndPos - BeginPos);
  162.   EndPos := Pos('.', Value);
  163.   IntValue := StrToInt(Copy(Value, 1, EndPos - 1), 0) * 60;
  164.   IntValue := IntValue + StrToInt(Copy(Value, EndPos + 1, Length(Value)), 0);
  165.   SetField(fieldLength, IntToStr(IntValue));
  166.  
  167.  
  168.  
  169.   DisplayResults;
  170. end;
  171.  
  172. begin
  173.   if CheckVersion(3,4,0) then
  174.   begin
  175.     MovieName := GetField(fieldOriginalTitle);
  176.     if MovieName = '' then
  177.       MovieName := GetField(fieldTranslatedTitle);
  178.     if Input('Cineguide (Cinebel) Import', 'Enter the title (or the URL) of the movie:', MovieName) then
  179.     begin
  180.       if Pos('cinebel.be', MovieName) > 0 then
  181.         AnalyzePage(MovieName)
  182.       else
  183.         AnalyzePage('http://www.cinebel.be/nl/srch.asp?mot='+UrlEncode(MovieName));
  184.     end;
  185.   end else
  186.     ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
  187. end.
  188.  
  189.